home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-10 | 13.8 KB | 494 lines | [TEXT/MPS ] |
- ##################################################################################################################
- ## General LaserWriter GX printing test library for Virtual User test environment ##
- ##################################################################################################################
- ## Developed by Brad Reigel and Scott Cutler, Apple Computer, Inc. ##
- ##################################################################################################################
- ## Last Modified July 19, 1994 ##
- ##################################################################################################################
-
- ## Initializate assumes the folowing:
- ## a folder name "Documents" is open on the Desktop.
- ## documents to be tested reside in the above folder.
-
- task Initialize()
- begin
- type k: { uparrowKey }; ## selects the first most document in window
- println "# Opening document…";
- pressKey k: { commandKey };
- type k: { 'O' }; ## Command - O
- releaseKey k: { commandKey };
- println "# Synchronizing…";
- results := PrintingEnabled(); ## determine if Print Item is enabled
- while not (results) ## if true
- results := PrintingEnabled(); ## determine if Print Item is enabled
- end;
-
- ## OpenAndPrintInitialize
- ## Opens document from finder and waits for print menu item to become active.
- ## WARNING: Some applications (esp Claris) make this item active before the document
- ## has actually finished opening.
-
- task OpenAndPrintInitialize()
- begin
- println "# Opening document…";
- pressKey k: { commandKey };
- type k: { 'O' }; ## Command - O
- releaseKey k: { commandKey };
- println "# Synchronizing…";
- results := PrintingEnabled(); ## determine if Print Item is enabled
- while not (results) ## if true
- results := PrintingEnabled(); ## determine if Print Item is enabled
- end;
-
- ## LoadNextDocument
- ## Gets next document.
-
- task LoadNextDocument()
- begin
- type k: { downarrowKey };
- println "# Opening document…";
- pressKey k: { commandKey };
- type k: { 'O' }; ## Command - O
- releaseKey k: { commandKey };
- println "# Synchronizing…";
- results := PrintingEnabled(); ## determine if Print Item is enabled
- while not (results) ## if true
- results := PrintingEnabled(); ## determine if Print Item is enabled
- end;
-
- ## Printing Enabled
- ## Checks to see if the Print menu item is enabled for selection. Returns true if Print is enabled.
- ## Returns false if Print is not enabled.
-
- task PrintingEnabled()
- begin
- match [menuItem t:/Print/ e:?PrintEnabled m:"File"];
- if (PrintEnabled)
- return true;
- else
- return false;
- end;
-
- ## SetPaper
- ## Accepts a string value and selects the appropriate radioButton.
- ## String: US Letter/US Legal/A4 Letter/B5 Letter/Tabloid (11x17)/Custom.
-
- task SetPaper(kPaper)
- begin
- if match [radioButton t:kPaper]
- begin
- select [radioButton t:kPaper]!;
- println "# Paper -> ",kPaper;
- end;
- end;
-
- ## SetOrientation
- ## Selects the appropriate icon for Portrait or Landscape orientation.
-
- task SetOrientation(kOrientation)
- begin
- match [window o:1 r:?portBounds];
- if (kOrientation = "Portrait")
- begin
- move a: { portBounds[1] + 115, portBounds[2] + 120 };
- click;
- println "# Orientation -> ",kOrientation;
- end;
- else
- begin
- move a: { portBounds[1] + 155, portBounds[2] + 120 };
- click;
- println "# Orientation -> ",kOrientation;
- end;
- end;
-
- ## SetScale
- ## Accepts a numeric value and types the value.
-
- task SetScale(kScale)
- begin
- match [window o:1 r:?portBounds];
- move a: { portBounds[1] + 300, portBounds[2] + 117 };
- doubleClick;
- type k: { kScale };
- println "# Scale -> ",kScale;
- end;
-
- ## SetCopies
- ## Accepts a numeric value and types the value.
-
- task SetCopies(kCopies)
- begin
- if (kCopies > 1)
- begin
- type k: { kCopies };
- println "# Copies -> ",kCopies;
- end;
- else
- println "# Copies -> 1";
- end;
-
- ## SetPages
- ## Accepts a string and selects the appropriate radioButton. String: All/From
- ## If string is From, two numeric value must be passed in.
-
- task SetPages(kPages, kFrom, kTo)
- begin
- if (kPages = "All")
- begin
- match [window o:1 r:?portBounds];
- move a: { portBounds[1] + 202, portBounds[2] + 47 };
- click;
- end;
- else
- begin
- match [window o:1 r:?portBounds];
- select [radioButton t:"From:"]!;
- move a: { portBounds[1] + 325, portBounds[2] + 44 };
- click;
- type k: { kFrom };
- println "# From -> ",kFrom;
- type k: { tabKey };
- type k: { kTo };
- println "# To -> ",kTo;
- end;
- end;
-
- ## SetCoverPage
- ## Accepts a string and selects the appropriate radioButton. String: No/First Page/Last Page
-
- task SetCoverPage(kCoverPage)
- begin
- match [radioButton t:kCoverPage]; ## is this needed?
- if (kCoverPage = "No")
- begin
- select [radioButton t:"No"]!;
- println "# Cover Page -> ",kCoverPage;
- end;
- else if (kCoverPage = "First Page")
- begin
- select [radioButton t:"First Page"]!;
- println "# Cover Page -> ",kCoverPage;
- end;
- else if (kCoverPage = "Last Page")
- begin
- select [radioButton t:"Last Page"]!;
- println "# Cover Page -> ",kCoverPage;
- end;
- end;
-
- ## SetPaperSource
- ## Sets Paper Source to default value "Paper Cassette".
-
- task SetPaperSource(kPaperSource := "Paper Cassette")
- begin
- if (kPaperSource = "Paper Cassette")
- begin
- select [radioButton t:"Paper Cassette"]!;
- println "# Paper Source -> ",kPaperSource;
- end;
- else
- begin
- select [radioButton t:"Manual Feed"]!;
- println "# Paper Source -> ",kPaperSource;
- end;
- end;
-
- ## SetPrintPreview
- ## Sets Print Preview to value passed.
-
- task SetPrintPreview(kPrintPreview)
- begin
- match [checkBox t:"Print Preview" s:?checked];
- if (kPrintPreview = true) and (checked[1] = 0)
- begin
- select [checkBox t:"Print Preview"]!;
- println "# Print Preview -> ",kPrintPreview;
- end;
- else if (kPrintPreview = false) and (checked[1] = 1)
- begin
- select [checkBox t:"Print Preview"]!;
- println "# Print Preview -> ",kPrintPreview;
- end;
- end;
-
- ## SetPrintUsingColor
- ## If kPrintUsingColor = "true", then prints color, else prints black & white.
- ## Works in applications with a "Print Using Color" checkbox in print dialog.
-
- task SetPrintUsingColor(kPrintUsingColor)
- begin
- match [checkBox t:"Print Using Color" s:?checked];
- if (kPrintUsingColor = true) and (checked[1] = 0)
- begin
- select [checkBox t:"Print Using Color"]!;
- println "# Print Usinf Color -> ",kPrintUsingColor;
- end;
- else if (kPrintUsingColor = false) and (checked[1] = 1)
- begin
- select [checkBox t:"Print Using Color"]!;
- println "# Print Usinf Color -> ",kPrintUsingColor;
- end;
- end;
-
- ## SetDestination
- ## Accepts four strings:
- ## The first string is destination. String: Printer/Disk File.
- ## The second string is file name. String: determined by scriptor.
- ## The third string is file format. Boolean: true = Print File/false = PostScript®.
- ## The fourth string is include fonts. Boolean: true = No Fonts/false = Fonts
-
- task SetDestination(kDestination, kName, kFormat, kFonts)
- begin
- if (kDestination = "Printer")
- begin
- select [radioButton t:"Printer"];
- println "# Destination -> ",kDestination;
- end;
- else
- begin
- select [radioButton t:"Disk File"];
- println "# Destination -> ",kDestination;
- type k: { returnKey };
- type k: { kName };
- println "# File Name -> ",kName;
- if (kFormat = false)
- begin
- match [window o:1 r:?portBounds];
- move a: { portBounds[1] + 226, portBounds[2] + 213 };
- pressMouse;
- move r: { 0, 15 };
- wait(1);
- releaseMouse;
- println "# Format -> PostScript®";
- end;
- else
- println "# Format -> Print File";
- if (kFonts = true)
- begin
- wait(2);
- select [checkBox t:"Don∂'t include fonts in file"];
- println "# Don’t include fonts in file -> ",kFonts;
- end;
- else
- println "# Don’t include fonts in file -> ",kFonts;
- SaveInFolder( "Disk Files" );
- end;
- type k: { returnKey };
- end;
-
- ## DialogPresent
- ## Checks the frontmost window and returns true if is a dialog. If window is not
- ## a dialog, return false.
-
- task DialogPresent()
- begin
- wait(15);
- match [window o:1 s:?windowStyle];
- if (windowStyle = dialog)
- return true;
- else if (windowStyle = movablemodal)
- return true;
- else if (windowStyle = shadow)
- return true;
- else
- return false;
- end;
-
- ## SetOptions
- ## Sets options in the options dialog depending on values passed in.
- ## Options dialog from Print dialog must be open when calling SetOptions.
-
- task SetOptions(kFlipHorz, kFlipVert, kInvertImage, kPrecisionBitmap)
- begin
-
- ### Flip Horizontal
- match [checkBox t:"Flip Horizontal" s:?kHorzChecked];
- wait(1);
- if (kFlipHorz = true) and (kHorzChecked[1] = 0)
- select [checkBox t:"Flip Horizontal"]!;
- else if (kFlipHorz = false) and (kHorzChecked[1] = 1)
- select [checkBox t:"Flip Horizontal"]!;
- println "# Flip Horizontal -> ",kFlipHorz;
-
- ### Flip Vertical
- match [checkBox t:"Flip Vertical" s:?kVertChecked];
- wait(1);
- if (kFlipVert = true) and (kVertChecked[1] = 0)
- select [checkBox t:"Flip Vertical"]!;
- else if (kFlipVert = false) and (kVertChecked[1] = 1)
- select [checkBox t:"Flip Vertical"]!;
- println "# Flip Vertical -> ",kFlipVert;
-
- ### Invert Image
- match [checkBox t:"Invert Image" s:?kInvertImageChecked];
- wait(1);
- if (kInvertImage = true) and (kInvertImageChecked[1] = 0)
- select [checkBox t:"Invert Image"]!;
- else if (kInvertImage = false) and (kInvertImageChecked[1] = 1)
- select [checkBox t:"Invert Image"]!;
- println "# Invert Image -> ",kInvertImage;
-
- ### Precision Bitmap Alingment
- match [checkBox t:/Precision Bitmap Alignment/ s:?kBitMapChecked];
- wait(1);
- if (kPrecisionBitmap = true) and (kBitMapChecked[1] = 0)
- select [checkBox t:/Precision Bitmap Alignment/];
- else if (kPrecisionBitmap = false) and (kBitMapChecked[1] = 1)
- select [checkBox t:/Precision Bitmap Alignment/];
- println "# Precision Bitmap Alingment -> ",kPrecisionBitmap;
-
- type k: { returnKey };
- end;
-
- ## SetPrintColorBitmap
- ## Prints using color bitmap, depending upon value passed in.
- ## Works in applications with a "Color" radio button in Print dialog.
-
- task SetPrintColorBitmap(kPrintColorBitmap)
- begin
- match [radioButton t:"Color" s:?enabled];
- if (kPrintColorBitmap = true) and (enabled[1] = 0)
- begin
- select [radioButton t:"Color"];
- println "# Print Color Bitmap -> Color";
- end;
- else if (kPrintColorBitmap = false) and (enabled[1] = 1)
- begin
- select [radioButton t:"Gray (Faster)"];
- println "# Print Color Bitmap -> Gray (Faster)";
- end;
- end;
-
- ## SetFractionalWidths
- ## Sets fractional widths option for text
-
- task SetFractionalWidths(kFractionalWidths)
- begin
- match [checkBox t:"Fractional Widths" s:?checked];
- if (kFractionalWidths = true) and (checked[1] = 0)
- select [checkBox t:"Fractional Widths"]!;
- else if (kFractionalWidths = false) and (checked[1] = 1)
- select [checkBox t:"Fractional Widths"]!;
- end;
-
- task SetUseAsDefault(kUseAsDefault)
- begin
- match [checkBox t:"Use As Default" s:?checked];
- if (kUseAsDefault = true) and (checked[1] = 0)
- select [checkBox t:"Use As Default"]!;
- else if (kUseAsDefault = false) and (checked[1] = 1)
- select [checkBox t:"Use As Default"]!;
- end;
-
- task SetPrintPostScriptOverText(kPrintPostScriptOverText)
- begin
- match [checkBox t:"Print PostScript Over Text" s:?checked];
- if (kPrintPostScriptOverText = true) and (checked[1] = 0)
- select [checkBox t:"Print PostScript Over Text"]!;
- else if (kPrintPostScriptOverText = false) and (checked[1] = 1)
- select [checkBox t:"Print PostScript Over Text"]!;
- end;
-
- ## Options are All, Odd Pages Only and Even Pages Only
- task SetPrintPages(kPrintPages := "All")
- begin
- if (kPrintPages <> "All")
- select [radioButton t:kPrintPages]!;
- else
- begin
- match [window o:1 r:?portBounds];
- move a: { portBounds[1] + 161, portBounds[2] + 143 };
- click;
- end;
- end;
-
- ## Quit
- ## Quits open application, pressing default key in "save document?" query dialog.
-
- task Quit()
- begin
- println "# Quiting…";
- select [menuItem t:"Quit" m:"File"];
- wait(2);
- if (DialogPresent())
- begin
- type k: { returnKey };
- println "# Saving…";
- end;
- else
- println "# No quit dialog appeared";
- end;
-
- ## SaveInFolder
- ## Saves files (such as PostScript) in the given folder located on the desktop.
-
- task SaveInFolder(kFolderName)
- begin
- select [button t:"Desktop"];
- type k: { tabKey };
- type k: { kFolderName };
- type k: { returnKey };
- end;
-
- ## DialogAction
- ## Presses button named kButtonName in frontmost dialog.
-
- task DialogAction(kButtonName)
- begin
- if (kButtonName = "Default")
- type k: { returnKey };
- else if (kButtonName = "OK")
- if (match [button t:"OK"])
- select [button t:"OK"];
- else if (kButtonName = "Cancel")
- if (match [button t:"Cancel"])
- select [button t: "Cancel"];
- println "# Dialog -> ", kButtonName;
- end;
-
- ## SetLWSCOrientation
- ## Sets orientation in Page Setup dialog for LWIISC driver.
-
- task SetLWSCOrientation(kOrientation)
- begin
- match [window o:1 r:?portBounds];
- if (kOrientation = "Portrait")
- begin
- move a: { portBounds[1] + 45, portBounds[2] + 130 };
- click;
- println "# Orientation -> ",kOrientation;
- end;
- else
- begin
- move a: { portBounds[1] + 80, portBounds[2] + 130 };
- click;
- println "# Orientation -> ",kOrientation;
- end;
- end;
-
- ## SetLWSCScale
- ## Sets scale in Page Setup dialog for LWIISC driver.
-
- task SetLWSCScale(kScale)
- begin
- kString := numToStr(kScale);
- select [radioButton t:kString+'%']!;
- println "# Scale -> ",kScale;
- end;
-
- ## SetLWSCOptions
- ## Sets options in Page Setup dialog for LWIISC driver.
-
- task SetLWSCOptions(kExactImage)
- begin
- match [checkBox t:/Exact Bit Images/ s:?kExactChecked];
- wait(1);
- if (kExactImage = true) and (kExactChecked[1] = 0)
- select [checkBox t:/Exact Bit Images/];
- else if (kExactImage = false) and (kExactChecked[1] = 1)
- select [checkBox t:/Exact Bit Images/];
- println "# Exact Bit Images -> ",kExactImage;
- end;
-
-